<?php
/**
 * Created by PhpStorm.
 * User: cyc
 * Date: 2017/11/1
 * Time: 下午2:53
 */

class ApiTaskService extends ApiBaseService
{

    public static function active_taskAction()
    {
        Task::activeTasks();
        return '';
    }


    public static function download_videoinfosAction()
    {
        $tasks =Task::model()->findAllByAttributes(['status' => Task::STATUS_TYPE_WAITING,]);
        /** @var Task $task */
        foreach ($tasks as $task)
        {
            $task->downLoadVideoInfos();
        }
        return '';
    }


    public static function load_videoinfosAction()
    {
        $tasks =Task::model()->findAllByAttributes(['status' => Task::STATUS_TYPE_PICKING,]);
        /** @var Task $task */
        foreach ($tasks as $task)
        {
            $task->loadVideosInfos();
        }
        return '';
    }


    public static function downLoad_videoscontentAction()
    {
        $tasks =Task::model()->findAllByAttributes(['status' => Task::STATUS_TYPE_DOWNING,]);
        /** @var Task $task */
        foreach ($tasks as $task)
        {
            $task->downLoadVideosContent();
        }
        return '';
    }

    public static function refresh_taskAction()
    {
        $tasks =Task::model()->findAllByAttributes(['status' => Task::STATUS_TYPE_COMPLETE]);
        /** @var Task $task */
        foreach ($tasks as $task)
        {
            $task->refreshTask();
        }
        return '';
    }

}